import { defineStore } from 'pinia';
import pkg from '../../../package.json';
import AppScssVar from '@/styles/var.scss';
import { TranslateTable } from '@/i18n';

const state = {
  language: 'zhCN' as keyof typeof TranslateTable,
  theme: 'light',
  version: pkg.version,
  fullLoading: false,
  loadingText: '加载ing...',
  styles: { ...AppScssVar },
};

const useAppStore = defineStore('app', {
  state: () => state,
  getters: {},
  actions: {
    /**
     * 修改系统语言
     * @param lang
     */
    setLanguage(lang: keyof typeof TranslateTable) {
      this.language = lang;
    },
    setFullLoading(b: boolean, text?: string) {
      this.fullLoading = b;
      if (text) {
        this.loadingText = text;
      }
    },
  },
});

export { useAppStore };
